<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function fn(a){
        if( a === 1){
            return 1
        }
        // console.log(`${a} * fun(${a}-1)`)
        return a * fn(a -1)
    }
    fn(3)
    // 尾递归
    function fnw(n,total){
        if( n === 1){
            return total
        }
        n*(n-1)*(n-2)
        console.log(n -1,n*total)
        return fnw(n -1 ,n*total)
    }
    console.log(fnw(3,1))
</script>
</body>
</html>
